<?php
session_start();
include("load-settings.php");

if(!isset($_SESSION['user']))
	header("Location: login.php");

$user = mysql_real_escape_string($_SESSION['user']);
$result = mysql_query("SELECT * FROM user WHERE id = $user");
$row = mysql_fetch_array($result);

if($row['type'] != 2)
	header("Location: home.php");
?>
<!doctype html>
<html>
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, maximum-scale=1, initial-scale=1, user-scalable=0">
    <link rel="icon" href="http://www.veteranboosters.com/wp-content/uploads/2014/04/favicon4.png" type="image/x-icon"/>
    <link rel="shortcut icon" href="http://www.veteranboosters.com/wp-content/uploads/2014/04/favicon4.png" type="image/x-icon"/>
  <!-- Always force latest IE rendering engine or request Chrome Frame -->
  <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">

  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,800">

  <!-- Use title if it's in the page YAML frontmatter -->
  <title>Veteran Boosters Order Tracking</title>


  <!--[if lt IE 9]>
  <script src="../../javascripts/vendor/html5shiv.js" type="text/javascript"></script>
  <script src="../../javascripts/vendor/excanvas.js" type="text/javascript"></script>
  <![endif]-->
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/font-awesome.css" />
<link rel="stylesheet" href="css/fullcalendar.css" />
<link rel="stylesheet" href="css/jquery.jscrollpane.css" />	
<link rel="stylesheet" href="css/unicorn.css" />
  <link href="stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
  <script src="javascripts/application.js" type="text/javascript"></script>
</head>

<?php
	include("top.php");
?>

  <div class="container-fluid padded">
    <div class="row-fluid">

      <!-- Breadcrumb line -->

      <div id="breadcrumb">
	  <a href="/" title="" class="tip-bottom" data-original-title="Go to Home"><i class="fa fa-home"></i> Home</a>
		<a href="#">Members</a>
		<a href="#" class="current">View and edit boosters    </a>
		
            </div>
    </div>
  </div>

  <div class="container-fluid padded">
  <div class="row-fluid">
   <div class="col-lg-12">
      <div class="box">
         <div class="box-header">
            <span class="title">Create new booster</span>
         </div>
         <div class="box-content">
            <table class="table table-bordered table-striped table-hover">
               <thead>
                  <tr>
                     <td>ID</td>
                     <td>Username</td>
					 <td>Password</td>
                     <td>Paypal</td>
					 <td>Level</td>
					 <td>Actions</td>
                  </tr>
               </thead>
               <tbody>
    <form action="booster-create.php" method="post">
    <tr>
        <td>3</td>
        <td>
            <input name="username" value="" type="text" style="margin-bottom: 0px; width: auto;">
        </td>
		<td>
            <input name="password" value="" type="text" style="margin-bottom: 0px; width: auto;">
        </td>
        <td>
            <input name="paypal" value="" type="text" style="margin-bottom: 0px; width: auto;">
        </td>
        <td>
            <select name="level" style="width: 70px; margin-bottom: 0px">
                <option value="0">Unauthorized</option>
                <option value="1">Gold 5</option>
                <option value="2">Gold 4</option>
                <option value="3">Gold 3</option>
				<option value="4">Gold 2</option>
				<option value="5">Gold 1</option>
				<option value="6">Platinum 5</option>
                <option value="7">Platinum 4</option>
                <option value="8">Platinum 3</option>
				<option value="9">Platinum 2</option>
				<option value="10">Platinum 1</option>
				<option value="11">Diamond 5</option>
                <option value="12">Diamond 4</option>
                <option value="13">Diamond 3</option>
				<option value="14">Diamond 2</option>
				<option value="15">Diamond 1</option>
				<option value="16">Challenger</option>
            </select>
        </td>
        <td>
            <input type="submit" class="btn btn-success btn-xs" value="Create">
        </td>
    </tr>
    </tbody>
	</form>
            </table>
         </div>
      </div>
   </div>
</div>
  <div class="row-fluid">
   <div class="col-lg-12">
      <div class="box">
         <div class="box-header">
            <span class="title">Boosters</span>
         </div>
         <div class="box-content">
            <table class="table table-bordered table-striped table-hover">
               <thead>
                  <tr>
                     <td>ID</td>
                     <td>Username</td>
                     <td>Paypal</td>
					 <td>Level</td>
					 <td>Simultaneous claims</td>
					 <td>Claim time limit</td>
				<!--	 <td>Approved for Duo</td>-->
					 <td>Actions</td>
                  </tr>
               </thead>
               <tbody>
			   <?php
					$result = mysql_query("SELECT * FROM user WHERE type = 1");

					while($row = mysql_fetch_array($result))
					{
						$level_select = "<select name = 'level' style = 'width: 70px; margin-bottom: 0px'>";

						if($row['level'] == 0)
							$level_select .= "<option value = '0' selected = 'selected'>Unauthorized</option>";
						else
							$level_select .= "<option value = '0'>Unauthorized</option>";

						if($row['level'] == 1)
							$level_select .= "<option value = '1' selected = 'selected'>Gold 5</option>";
						else
							$level_select .= "<option value = '1'>Gold 5</option>";

						if($row['level'] == 2)
							$level_select .= "<option value = '2' selected = 'selected'>Gold 4</option>";
						else
							$level_select .= "<option value = '2'>Gold 4</option>";

						if($row['level'] == 3)
							$level_select .= "<option value = '3' selected = 'selected'>Gold 3</option>";
						else
							$level_select .= "<option value = '3'>Gold 3</option>";

						if($row['level'] == 4)
							$level_select .= "<option value = '4' selected = 'selected'>Gold 2</option>";
						else
							$level_select .= "<option value = '4'>Gold 2</option>";

						if($row['level'] == 5)
							$level_select .= "<option value = '5' selected = 'selected'>Gold 1</option>";
						else
							$level_select .= "<option value = '5'>Gold 1</option>";

						if($row['level'] == 6)
							$level_select .= "<option value = '6' selected = 'selected'>Platinum 5</option>";
						else
							$level_select .= "<option value = '6'>Platinum 5</option>";

						if($row['level'] == 7)
							$level_select .= "<option value = '7' selected = 'selected'>Platinum 4</option>";
						else
							$level_select .= "<option value = '7'>Platinum 4</option>";

						if($row['level'] == 8)
							$level_select .= "<option value = '8' selected = 'selected'>Platinum 3</option>";
						else
							$level_select .= "<option value = '8'>Platinum 3</option>";

						if($row['level'] == 9)
							$level_select .= "<option value = '9' selected = 'selected'>Platinum 2</option>";
						else
							$level_select .= "<option value = '9'>Platinum 2</option>";

						if($row['level'] == 10)
							$level_select .= "<option value = '10' selected = 'selected'>Platinum 1</option>";
						else
							$level_select .= "<option value = '10'>Platinum 1</option>";

						if($row['level'] == 11)
							$level_select .= "<option value = '11' selected = 'selected'>Diamond 5</option>";
						else
							$level_select .= "<option value = '11'>Diamond 5</option>";

						if($row['level'] == 12)
							$level_select .= "<option value = '12' selected = 'selected'>Diamond 4</option>";
						else
							$level_select .= "<option value = '12'>Diamond 4</option>";

						if($row['level'] == 13)
							$level_select .= "<option value = '13' selected = 'selected'>Diamond 3</option>";
						else
							$level_select .= "<option value = '13'>Diamond 3</option>";

						if($row['level'] == 14)
							$level_select .= "<option value = '14' selected = 'selected'>Diamond 2</option>";
						else
							$level_select .= "<option value = '14'>Diamond 2</option>";

						if($row['level'] == 15)
							$level_select .= "<option value = '15' selected = 'selected'>Diamond 1</option>";
						else
							$level_select .= "<option value = '15'>Diamond 1</option>";

						if($row['level'] == 16)
							$level_select .= "<option value = '16' selected = 'selected'>Challenger</option>";
						else
							$level_select .= "<option value = '16'>Challenger</option>";

						$level_select .= "</select>";

						$duo_select = "<select name = 'duo_approved' style = 'width: 70px; margin-bottom: 0px'>";

						if($row['duo_approved'] == 0)
							$duo_select .= "<option value = '0' selected = 'selected'>No</option>";
						else
							$duo_select .= "<option value = '0'>No</option>";

						if($row['duo_approved'] == 1)
							$duo_select .= "<option value = '1' selected = 'selected'>Yes</option>";
						else
							$duo_select .= "<option value = '1'>Yes</option>";

						$duo_select .= "</select>";

						echo "<form action = 'booster-update.php' method = 'post'><input name = 'id' type = 'hidden' value = '".$row['id']."' />";
						echo "<tr><td>".$row['id']."</td>";
						echo "<td><input style='width:100px' name = 'username' value = '".$row['username']."' type = 'text' style = 'margin-bottom: 0px;' /></td>";
						echo "<td><input  style='width:100px' name = 'paypal' value = '".$row['paypal']."' type = 'text' style = 'margin-bottom: 0px;' /></td>";
						echo "<td>".$level_select."</td>";
						echo "<td><input style = 'width: 70px' name = 'max_claims' value = '".$row['max_claims']."' /></td>";
						echo "<td><input style = 'width: 70px' name = 'claim_time_limit' value = '".$row['claim_time_limit']."' /></td>";
					//	echo "<td>".$duo_select."</td>";
						echo "<td><input type = 'submit' class='btn btn-success btn-xs' value = 'Update' /><a href = 'delete_user.php?id=".$row['id']."' class = 'btn btn-success btn-xs' onclick = 'check_confirm(event)'>Delete</a></td></tr></form>";
					}
			   ?>
			   </tbody>
            </table>
         </div>
      </div>
   </div>
</div>
<script>
function ban (id)
{
	var reason = prompt("Please enter ban reason for user "+id+": ", "");

	if(reason != null)
	{
		window.location = "http://eloedge.com/track/ban.php?id="+id+"&ban_reason="+reason;
	}
}
function check_confirm (event)
{
	if(!confirm("Are you sure?"))
	{
		event.preventDefault();
		event.stopPropagation();
		return false;
	}
}
</script>
</div>
</div>
<?php
	include("bottom.php");
?>